import { Role } from '@/constants/role'
import { RouterName } from '@/router/name'
import { MIMORoute } from '@/modules/mimo/route'
import { mergeMeta } from '../merge-meta'

export const courseRoutes = mergeMeta(
  [
    {
      path: 'courses',
      name: RouterName.Course,
      redirect: { name: RouterName.CourseList },
      meta: {
        hideInMenu: false,
        hideChildrenInMenu: true,
        menuTitle: 'navigation.course.title',
        icon: 'i-fluent-library-28-filled'
      },
      children: [
        {
          path: '',
          name: RouterName.CourseList,
          meta: {
            isLink: false,
            menuTitle: 'navigation.course.title'
          },
          component: () => import('@/pages/CoursePage/CourseList/index.vue')
        },
        {
          path: ':classID',
          name: RouterName.CourseDetail,
          meta: { menuTitle: 'navigation.course.detail' },
          component: () => import('@/pages/CoursePage/CourseDetail/index.vue')
        },
        {
          path: ':classID',
          name: 'experiment-to-course-detail',
          redirect(to) {
            /** 用于在实验页面通过面包屑导航回课程详情 */
            return { name: RouterName.CourseDetail, query: to.query, params: to.params }
          },
          meta: { menuTitle: 'navigation.course.detail' },
          children: [MIMORoute]
        }
      ]
    }
  ],
  {
    requireAuth: true,
    role: Role.Student,
    isLink: true
  }
)
